package com.gitee.huxing.framework.core.aspecj;

import com.gitee.huxing.framework.core.ServiceInterceptorHandler;
import com.gitee.huxing.framework.core.filter.Filter;
import com.gitee.huxing.framework.core.module.ResponseInfo;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.framework.core
 * @ClassName: UserMethodInterceptor
 * @Author: huxing
 * @DateTime: 2021-10-08 下午1:46
 */
public class UserMethodInterceptor implements MethodInterceptor {

    @Nullable
    @Override
    public Object invoke(@Nonnull MethodInvocation methodInvocation) throws Throwable {
        String methodName = methodInvocation.getMethod().getName();
        System.out.println("调用的方法名: " + methodName);
        try {
            return methodInvocation.proceed();
        } catch (Exception ex){
            ex.printStackTrace();
            return ResponseInfo.error(ex);
        }
    }
}
